/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */

package com.aionemu.gameserver.model.templates.npcTemplate;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;

import com.aionemu.gameserver.model.Race;
import com.aionemu.gameserver.model.TribeClass;
import com.aionemu.gameserver.model.templates.NpcWhichNotGatherableTemplate;

/**
 * @author Mr. Poke
 *
 */

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NpcTemplate", propOrder =
{ "boundRadius", "commonData", "functionData" })
@XmlSeeAlso(
{ KiskTemplate.class, CreatureTemplate.class, ActionItemTemplate.class })
public class NpcTemplate extends NpcWhichNotGatherableTemplate
{

	@XmlElement(name = "bound_radius")
	protected BoundRadius	boundRadius;
	@XmlElement(name = "common_data")
	protected NpcCommonData	commonData;
	protected FunctionData	functionData;
	@XmlAttribute(name = "npc_id", required = true)
	protected int			npcId;
	@XmlAttribute
	protected String		name;
	@XmlAttribute
	protected Byte			level;
	@XmlAttribute(name = "talking_distance")
	protected Integer		talkingDistance;

	/**
	 * Gets the value of the boundRadius property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link BoundRadius }
	 *     
	 */
	public BoundRadius getBoundRadius()
	{
		if (boundRadius == null)
			return BoundRadius.boundRadius;
		else
			return boundRadius;
	}

	/**
	 * Gets the value of the commonData property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link NpcCommonData }
	 *     
	 */
	public NpcCommonData getCommonData()
	{
		return commonData;
	}

	/**
	 * Gets the value of the name property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link String }
	 *     
	 */
	@Override
	public String getName()
	{
		if (name == null)
		{
			return "";
		}
		else
		{
			return name;
		}
	}

	/**
	 * Gets the value of the level property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link Byte }
	 *     
	 */
	@Override
	public byte getLevel()
	{
		if (level == null)
		{
			return ((byte) 1);
		}
		else
		{
			return level;
		}
	}

	/**
	 * Gets the value of the talkingDistance property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link Integer }
	 *     
	 */
	public int getTalkingDistance()
	{
		if (talkingDistance == null)
		{
			return 0;
		}
		else
		{
			return talkingDistance;
		}
	}

	@Override
	public TribeClass getTribe()
	{
		return this.commonData.getTribe();
	}

	@Override
	public Race getRace()
	{
		return this.commonData.getRace();
	}

	@Override
	public int getTemplateId()
	{
		return this.npcId;
	}

	@Override
	public int getNameId()
	{
		return commonData.getNameId();
	}

	/* (non-Javadoc)
	 * @see com.aionemu.gameserver.model.templates.NpcWhichNotGatherableTemplate#setTribe(com.aionemu.gameserver.model.TribeClass)
	 */
	@Override
	public void setTribe(TribeClass tribe)
	{
		//TODO Need???
	}

	/**
	 * Gets the value of the functionData property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link FunctionData }
	 *     
	 */
	public FunctionData getFunctionData()
	{
		return functionData;
	}
}
